/*
 * @LastEditTime: 2023-03-16 20:52:41
 * @Method: 归并排序
 * @Description: 
 */
package AcWing;

import java.util.Scanner;

public class Solution787 {

    public static int[] mergeSort (int[] nums, int l, int r) {
        if (l > r) {
            return new int[]{};
        }
        if (l == r) {
            return new int[]{nums[l]};    
        }
        int m = l + (r - l) / 2;
        int[] l_array = mergeSort(nums, l, m);
        int[] r_array = mergeSort(nums, m + 1, r);
        return merge(l_array, r_array);
    }

    public static int[] merge (int[] nums1, int[] nums2) {
        int[] t = new int[nums1.length + nums2.length];
        int index = 0;
        int i = 0, j = 0; 
        for (;i < nums1.length && j < nums2.length;) {
            if (nums1[i] <= nums2[j]) {
                t[index++] = nums1[i++];
            } else {
                t[index++] = nums2[j++];
            }
        }
        for (;i < nums1.length;) {
            t[index++] = nums1[i++];
        }
        for (;j < nums2.length;) {
            t[index++] = nums2[j++];
        }
        return t;
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        int[] nums = new int[m];
        int index = 0;
        while (m-- > 0) {
            nums[index++] = sc.nextInt();
        }
        int[] res = mergeSort(nums, 0, nums.length - 1);
        for (int i = 0;i < res.length;i++) {
            System.out.print(res[i]);
            if (i < res.length - 1) {
                System.out.print(" ");
            }
        }
    }
}
